package com.mia.props.client.container.guilib;

import java.util.ArrayList;
import java.util.List;

public class GuiElement implements IGuiMouseAware, IGuiTooltip {
   protected final IExposedGui parent;
   protected int posX;
   protected int posY;
   protected int width_element;
   protected int height_element;
   protected final float guiScale = 0.00390625F;
   protected boolean tooltipEnabled = false;
   protected List tooltipText = new ArrayList();

   public GuiElement(IExposedGui parent, int x, int y, int width, int height) {
      this.parent = parent;
      this.posX = x;
      this.posY = y;
      this.width_element = width;
      this.height_element = height;
   }

   public int posX() {
      return this.parent.getGuiLeft() + this.posX;
   }

   public int posY() {
      return this.parent.getGuiTop() + this.posY;
   }

   public boolean isTooltipEnabled() {
      return this.tooltipEnabled;
   }

   public void update() {
   }

   public List getTooltipText(int mouseX, int mouseY) {
      return this.tooltipText;
   }

   /** @deprecated */
   @Deprecated
   public int getHeight() {
      return this.height_element;
   }

   public boolean mouseOver(int mouseX, int mouseY) {
      return mouseX >= this.posX() && mouseX <= this.posX() + this.width_element && mouseY >= this.posY() && mouseY <= this.posY() + this.height_element;
   }

   protected void drawGuiAlignedString(String text, int x, int y, TextAlign alignment, int color) {
      int textAnchorL = 0;
      if (alignment == TextAlign.CENTER) {
         textAnchorL = -this.parent.getFontRenderer().getStringWidth(text) / 2;
      } else if (alignment == TextAlign.RIGHT) {
         textAnchorL = -this.parent.getFontRenderer().getStringWidth(text);
      }

      this.parent.getFontRenderer().drawString(text, this.parent.getGuiLeft() + x + textAnchorL, this.parent.getGuiTop() + y, color);
   }
}
